# SleepMirror - A reflection of your sleep quality
# 
# sm_util.rb
# This is a utilities module for little things we need, like UUIDs.
# 
# 
# ©2010 JohnGary, LLC.  All Rights Reserved.
# 
# 
# Changelog:
# 
# 
# 
require 'Win32API'

module SM_util
  #gen_uuid leverage the Windows dlls to generate UUIDs, so this will only
  #work on a Windows Platform.
  def SM_util.gen_uuid
    uuid_create = Win32API.new('rpcrt4', 'UuidCreate', 'P', 'L')
    result = " " * 16 #allocate a 16 string of blanks to hold the uuid
    uuid_create.call(result) #invoke the UuidCrete fx from Win32API
    a,b,c,d,e,f,g,h = result.unpack('SSSSSSSS')
    sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', a, b, c, d, e, f, g, h)
  end
end
